﻿Module modInventoryTransfer



    Function CreateButton_InventoryTransfer(ByRef oForm As SAPbouiCOM.Form, ByRef sErrDesc As String) As Long

        Try
            sFuncName = "CreateButton_InventoryTransfer()"
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Startung Function", sFuncName)

            Dim oitm As SAPbouiCOM.Item = oForm.Items.Add("btnCpyFrm", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            Dim oBtn As SAPbouiCOM.Button
            oitm.Top = oForm.Items.Item("2").Top
            'oitm.Left = (oForm.Items.Item("2").Left + oForm.Items.Item("2").Width + 5) 1250000074
            oitm.Left = (oForm.Items.Item("1250000074").Left + oForm.Items.Item("1250000074").Width + 5)
            oitm.Width = oForm.Items.Item("1250000074").Width
            oitm.Height = oForm.Items.Item("2").Height
            oBtn = oitm.Specific
            oBtn.Caption = "Copy From PR"
            oitm.FromPane = 0
            oitm.ToPane = 0

            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with SUCCESS", sFuncName)
            CreateButton_InventoryTransfer = RTN_SUCCESS

        Catch ex As Exception
            sErrDesc = ex.Message().ToString()
            Call WriteToLogFile(sErrDesc, sFuncName)
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with ERROR", sFuncName)
            CreateButton_InventoryTransfer = RTN_ERROR
        End Try

    End Function

    Function Fill_MatrixValues_InventoryTransfer(ByRef oForm As SAPbouiCOM.Form, ByRef sErrDesc As String) As Long

        Dim oMatrix As SAPbouiCOM.Matrix
        Dim iRowCount As Integer = 0

        Try

            sFuncName = "Fill_MatrixValues_InventoryTransfer()"
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Startung Function", sFuncName)

            oMatrix = oForm.Items.Item("23").Specific

            iRowCount = oMatrix.VisualRowCount


            p_oSBOApplication.StatusBar.SetText("Please Wait While Loading the Values...", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

            oForm.Freeze(True)

            If Not oDTSelectedRows Is Nothing And oDTSelectedRows.Rows.Count > 0 Then

                For iDTRowCount As Integer = 0 To oDTSelectedRows.Rows.Count - 1

                    'Fill the  Details

                    iRowCount = iRowCount + 1

                    oMatrix.Columns.Item("1").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(2).ToString()
                    oMatrix.Columns.Item("10").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(7).ToString()

                    'oMatrix.Columns.Item("1470001039").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(6).ToString()
                    oMatrix.Columns.Item("5").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(6).ToString()
                    oMatrix.Columns.Item("10001005").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(4).ToString()
                    oMatrix.Columns.Item("10001011").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(5).ToString()

                    oMatrix.Columns.Item("U_AB_BaseType").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(9).ToString()
                    oMatrix.Columns.Item("U_AB_BaseEntry").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(10).ToString()
                    oMatrix.Columns.Item("U_AB_BaseLineNum").Cells.Item(iRowCount - 1).Specific.value = oDTSelectedRows.Rows(iDTRowCount)(11).ToString()

                Next

                p_oSBOApplication.StatusBar.SetText("Values Loaded Based on Selection", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)

                oForm.Freeze(False)

            End If
            Fill_MatrixValues_InventoryTransfer = RTN_SUCCESS
        Catch ex As Exception
            sErrDesc = ex.Message().ToString()
            Call WriteToLogFile(sErrDesc, sFuncName)
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with ERROR", sFuncName)
            oForm.Freeze(False)
            Fill_MatrixValues_InventoryTransfer = RTN_ERROR
        End Try
    End Function


End Module
